package cn.zdm.dynamicdatasource.config.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * copyright (C), 2021, 武大吉奥科技有限公司
 *
 * @Program dynamic-datasource
 * @Description swagger配置
 * @Author ZhaoDeman
 * @Create 2021/1/19 13:57
 * @Version 1.0.0
 * <author>                <time>                  <version>                   <description>
 * ZhaoDeman        2021/1/19 13:57                 1.0                        swagger配置
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig2 {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.zdm.dynamicdatasource.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    @Bean
    public ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("动态切换数据源")
                .version("1.0.0")
                .description("动态切换数据源测试")
                .contact(new Contact("zhaodeman", null, "zhaodeman@163.com"))
                .build();
    }
}
